<?php
class MinimalresultsController extends AppController {

	var $name = 'Minimalresults';
	var $helpers = array('Html', 'Form');

	function index() {
		$this->Minimalresult->recursive = 0;
		$this->set('minimalresults', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Minimalresult', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('minimalresult', $this->Minimalresult->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Minimalresult->create();
			if ($this->Minimalresult->save($this->data)) {
				$this->Session->setFlash(__('The Minimalresult has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The Minimalresult could not be saved. Please, try again.', true));
			}
		}
		$professions = $this->Minimalresult->Profession->find('list');
		$subjects = $this->Minimalresult->Subject->find('list');
		$this->set(compact('professions', 'subjects'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Minimalresult', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Minimalresult->save($this->data)) {
				$this->Session->setFlash(__('The Minimalresult has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The Minimalresult could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Minimalresult->read(null, $id);
		}
		$professions = $this->Minimalresult->Profession->find('list');
		$subjects = $this->Minimalresult->Subject->find('list');
		$this->set(compact('professions','subjects'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Minimalresult', true));
			$this->redirect(array('action' => 'index'));
		}
		if ($this->Minimalresult->del($id)) {
			$this->Session->setFlash(__('Minimalresult deleted', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->Session->setFlash(__('The Minimalresult could not be deleted. Please, try again.', true));
		$this->redirect(array('action' => 'index'));
	}

}
?>